cmake_minimum_required(VERSION 3.4.1)

set(lib_src_DIR ${CMAKE_SOURCE_DIR}/libs/armeabi-v7a)
include_directories(
     ${CMAKE_SOURCE_DIR}/src/main/cpp/include
)
add_library(sdl2_lib SHARED IMPORTED)
set_target_properties(sdl2_lib PROPERTIES IMPORTED_LOCATION
    ${lib_src_DIR}/libSDL2.so)



add_library(sdl2ttf_lib SHARED IMPORTED)
set_target_properties(sdl2ttf_lib PROPERTIES IMPORTED_LOCATION
    ${lib_src_DIR}/libSDL2_ttf.so)

#add_library(sdlmain_lib SHARED IMPORTED)
#set_target_properties(sdlmain_lib PROPERTIES IMPORTED_LOCATION
#    ${lib_src_DIR}/libmain.so)

add_library( native-lib  SHARED
             src/main/cpp/global.h
             src/main/cpp/decoder.h
             src/main/cpp/decoder.cpp
             src/main/cpp/sdlmgr.cpp
             src/main/cpp/sdlmgr.h
             src/main/cpp/native-lib.cpp
             src/main/cpp/SDL_android_main.c
             )

find_library(log-lib    log )
find_library(GLESv1_CM-lib    GLESv1_CM )
find_library(GLESv2-lib    GLESv2 )

#ffmpeg libs
add_library( avcodec
             SHARED
             IMPORTED)
set_target_properties( avcodec
                       PROPERTIES IMPORTED_LOCATION
                       ${lib_src_DIR}/libavcodec.so)

add_library( avfilter
             SHARED
             IMPORTED)
set_target_properties( avfilter
                       PROPERTIES IMPORTED_LOCATION
                       ${lib_src_DIR}/libavfilter.so)

add_library( avformat
             SHARED
             IMPORTED)
set_target_properties( avformat
                       PROPERTIES IMPORTED_LOCATION
                       ${lib_src_DIR}/libavformat.so)

add_library( avutil
             SHARED
             IMPORTED)
set_target_properties( avutil
                       PROPERTIES IMPORTED_LOCATION
                       ${lib_src_DIR}/libavutil.so)

add_library( swresample
             SHARED
             IMPORTED)
set_target_properties( swresample
                       PROPERTIES IMPORTED_LOCATION
                       ${lib_src_DIR}/libswresample.so)

add_library( swscale
             SHARED
             IMPORTED)
set_target_properties( swscale
                       PROPERTIES IMPORTED_LOCATION
                       ${lib_src_DIR}/libswscale.so)

target_link_libraries(  native-lib
                       ${log-lib}
                       ${GLESv1_CM-lib}
                       ${GLESv2-lib}
                       sdl2_lib
                       sdl2ttf_lib
 #                      sdlmain_lib
                       avcodec
                       avfilter
                       avformat
                       avutil
                       swresample
                       swscale
                       )